added samples
[windows-sources.git] / sdk / samples / all in on code / Visual Studio 2008 / CSAzureTableStorageWCFDS / DataServiceWebRole / Entities / PersonTableStorageContext.cs
blob92e92cd346d3ca77091b1d3f58f77a99c3274d23
1 /****************************** Module Header ******************************\
2 * Module Name: PersonTableStorageContext.cs
3 * Project: CSAzureTableStorageWCFDS
4 * Copyright (c) Microsoft Corporation.
5 *
6 * This is the table storage context.
7 * Do not confuse it with PersonDataServiceContext (the WCF Data Service object context).
8 *
9 * This source is subject to the Microsoft Public License.
10 * See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
11 * All other rights reserved.
13 * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
14 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
16 \***************************************************************************/
18 using System.Linq;
19 using Microsoft.WindowsAzure;
20 using Microsoft.WindowsAzure.StorageClient;
22 namespace WebRole.Entities
24 /// <summary>
25 /// This is the table storage context.
26 /// Do not confuse it with PersonDataServiceContext (the WCF Data Service object context).
27 /// Table storage contexts should derive from TableServiceContext.
28 /// </summary>
29 public class PersonTableStorageContext : TableServiceContext
31 private static CloudStorageAccount account;
32 public static string TableName = "Person";
34 static PersonTableStorageContext()
36 account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
37 CloudTableClient tableClient = new CloudTableClient(account.TableEndpoint.AbsoluteUri, account.Credentials);
38 tableClient.CreateTableIfNotExist(TableName);
41 public PersonTableStorageContext()
42 : base(account.TableEndpoint.AbsoluteUri, account.Credentials)
46 public IQueryable<Person> Person
48 get { return this.CreateQuery<Person>(TableName); }